const commonLangs = require.context('@/locale/', true, /\.json$/);
const componentsLangs = require.context('@/components/', true, /\lang.js$/);
const messages = {}
commonLangs.keys().map((modulePath) => {
	if (modulePath.includes('uni-app')) return
	const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1');
	const value = commonLangs(modulePath);
	messages[moduleName] = value
});
componentsLangs.keys().map((modulePath) => {
	const value = componentsLangs(modulePath);
	Object.keys(messages).map(type => {
		// 排除建了lang.js没有内容时报错
		if ((typeof value == 'object') && value.default) {
			messages[type] = { ...value.default[type], ...messages[type] }
		}
	})
});
export const i18nConfig = {
	locale: uni.getLocale(),
	messages
}